<?php
/**
 * Controller for app
 */
require_once 'app/env.php';

//show submit form, or do feedback saving
if (@$_GET['action'] == 'save') {
	$view = new Views\Feedback($_SESSION['l']);
	$view->saveForm($_POST);
} else {
	switch (@$_GET['page']) {
		case 'feedback':
			$view = new Views\Feedback($_SESSION['l']);
			$view->viewForm($_GET['b']);
		break;
		case 'bestCompanies':
			$view = new Views\Business($_SESSION['l']);
			$catId = (int)@$_GET['b'];
			if ($catId == 0) {
				$catId = 1;
			}
			$view->viewTopBusinesses($catId);
			break;
		case 'myComments':
			$view = new Views\Business($_SESSION['l']);
			$view->viewMyScoresAndComments((int)@$_GET['b']);
			break;
		case 'myAnalytics':
			$view = new Views\Business($_SESSION['l']);
			$view->viewMyAnalytics((int)@$_GET['b']);
			break;
					
		case 'companyDetails':
			$view = new Views\Business($_SESSION['l']);
			$view->viewBusinessDetails((int)@$_GET['b']);
			break;
		case 'mobile':
			$view = new Views\Feedback($_SESSION['l']);
			$view->viewPortableForm($_GET['b']);
			break;
		default:
			$view = new Views\Business($_SESSION['l']);
			$view->viewWelcomePage();
		break;
	}
	
}
